package micro.controller.userMeun;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import micro.pojo.employee;
import micro.pojo.employees;
import micro.service.login.hrService;
import micro.service.userMeun.userspace;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpSession;
import java.util.List;
@Controller
@RequestMapping("/user")
public class userMenu {
    @Autowired
    private micro.service.userMeun.userspace userspace;
    @RequestMapping("/order")
    public String order(@RequestParam(required = false, defaultValue = "1") Integer page, Model model, HttpSession session, @RequestParam(value = "name",defaultValue="")String name,
                        @RequestParam(value = "currentPage",
                                required = false) Integer currentPage) {
        if (currentPage == null) {
            PageHelper.startPage(page, 10);
        } else {
            PageHelper.startPage(currentPage, 10);
        }
        if (name!=null) {
            session.setAttribute("name",name);
            System.out.println(name);

            System.out.println("31231");
           List<employees> employees1=userspace.ose(name);
            PageInfo<employees> e=new PageInfo<>(employees1);
            model.addAttribute("page",e);
            model.addAttribute("list",employees1);
            System.out.println("模糊查询");
        }else {
            List<employees> employees=userspace.listos();
            System.out.println(employees);
            PageInfo<employees> e = new PageInfo<>(employees);
            model.addAttribute("page", e);
            model.addAttribute("list", employees);
            System.out.println("-----------1231231231231n");
        }
        return "userMeun/userList";
    }
    @RequestMapping("/omg")
    public String loginlist() {
        System.out.println("-----------login");
        return "index";
    }
}
